package com.wed.db;

import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.xml.internal.ws.api.pipe.NextAction;

/**
 * Servlet implementation class SubmitServlet
 */
@WebServlet("/SubmitServlet")
public class SubmitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SubmitServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int idVersion=Integer.parseInt(request.getParameter("idVersion"));
		int idAssi=Integer.parseInt(request.getParameter("AssignmentId"));
		double x=0;
		String user=request.getParameter("username");
		ConnectDB db=new ConnectDB();
		try
		{
		ArrayList<RalationConcept> RlSV=new ConnectDB().getConceptByID(idVersion);
		ArrayList<posiConceptGV> RlGV=new ConnectDB().getPosiByID(idAssi);
	//	int concept1=0,concept2=0,relation=0;
		 x=db.cham(RlSV, RlGV);		
		//cập nhật tình trạng của score trong cmapstudent là 
		if(db.UpDateScoreCmapstudent(idVersion,x))
		{
			RequestDispatcher dispacher=request.getRequestDispatcher("KetquaSubmit.jsp");
			dispacher.forward(request, response);
		}		
		}
		catch(Exception e)
		{
			
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
